<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="单据编号" prop="code">
        <el-input
          v-model="queryParams.code"
          placeholder="请输入单据编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="源单据号" prop="sourceCode">
        <el-input
          v-model="queryParams.sourceCode"
          placeholder="请输入源单据号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="单据阶段" prop="docStage">
        <el-input
          v-model="queryParams.docStage"
          placeholder="请输入单据阶段"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="单据日期" prop="docDate">
        <el-date-picker clearable
                        v-model="queryParams.docDate"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择单据日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>



    <el-table v-loading="loading" :data="cgbjList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="主键" align="center" prop="id"/>
      <el-table-column label="单据编号" align="center" prop="code" width="200" fixed="left"/>
      <el-table-column label="源单据号" align="center" prop="sourceCode" width="200"/>
      <el-table-column label="单据阶段" align="center" prop="docStage"/>
      <el-table-column label="单据日期" align="center" prop="docDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.docDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="制单人主键id" align="center" prop="docMakeUserId"/>
      <el-table-column label="创建人" align="center" prop="createBy"/>
      <el-table-column label="创建时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="修改人" align="center" prop="updateBy"/>
      <el-table-column label="修改时间" align="center" prop="updateTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="remark"/>
    </el-table>
    <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
    />

  </div>
</template>

<script>
import {listGysbj, getGysbj, delGysbj,delGysbjPlus, addGysbj, updateGysbj, updateGysbjPlus,addGysbjPlus, getGysbjPlus} from "@/api/caigou/gysbj";
import {listBuyComparePrice} from "@/api/caigou/buyComparePrice";
import SelectBuyAsk from "@/views/caigou/gysbj/SelectBuyAsk.vue";
import MyNumberInput from "@/views/caigou/gysbj/MyNumberInput.vue";
//采购比价
export default {
  name: "CgBj",
  components: {SelectBuyAsk,MyNumberInput},
  data() {
    return {
      // 多选比价单
      bjdList:[],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 采购比价表格数据
      cgbjList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        code: null,
        sourceCode: null,
        docStage: null,
        approvalResult: null,
        isEffect: null,
        isClose: null,
        isCancel: null,
      },
      // 表单参数
      form: {},
    };
  },
  computed:{

  },
  created() {
    this.getList();
  },
  methods: {
    returnBjdList(){
      return this.bjdList;
    },


    /** 查询供应商报价列表 */
    getList() {
      this.loading = true;
      listBuyComparePrice(this.queryParams).then(response => {
        this.cgbjList = response.rows;
        this.total = response.total;
        this.loading = false;
      });

    },

    // 表单重置
    reset() {
      this.form = {
        id: null,
        code: 'GYBJ-' + Date.now(),
        sourceCode: null,
        docStage: null,
        supplierId: null,
        approvalResult: null,
        isEffect: null,
        isClose: null,
        isCancel: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        isDel: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.bjdList = selection;

    },

  },
  activated() {
    this.bjdList = [];
  }
};
</script>
